<?php
/**
 * Joomla! 1.5 component eventcalendar
 *
 * @version $Id: eventcalendar.php 2010-10-01 08:17:29 svn $
 * @author Pasi Lampinen
 * @package Joomla
 * @subpackage eventcalendar
 * @license GNU/GPL
 *
 * Tapahtumakalenteri Joomlaan geolokaatiolla
 *
 * This component file was created using the Joomla Component Creator by Not Web Design
 * http://www.notwebdesign.com/joomla_component_creator/
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

require_once JPATH_ADMINISTRATOR.DS.'components'.DS.'com_eventcalendar'.DS.'helpers'.DS.'database.php';

/**
 * eventcalendar Component eventcalendar Model
 *
 * @author      notwebdesign
 * @package		Joomla
 * @subpackage	eventcalendar
 * @since 1.5
 */

/*
class TableTapahtuma extends JTable
{
   
     var $id = null;

    var $tapahtuma_luokka_id = null;
    var $alku_aika;	

    var $loppu_aika= null;
  
    var $nimi = null;

    var $kuva= null;
    var $kuvaus= null;
    var  $toistuminen= null;
    var $tila= null;

    var $paikka_teksti= null;
    var $position_id= null;

    var $yhteys_henkilo_nimi= null;
    var $yhteys_henkilo_tiedot= null;

     var $promo= null;

     var $kotikalenteri_id= null;
     var $liitetiedosto= null;
 
    function __construct( &$db ) {
        parent::__construct(getGlobalDbPrefix()."tapahtuma", 'id', $db);
    }
}
*/


class EventcalendarModelShowevent extends JModel {
    /**
	 * Constructor
	 */
	function __construct() {
		parent::__construct();
		$this->alustaDb();
    }
	
		/* Haetaan tapahtumat */
	var $_eventData;
	var $_picture;
	
	function alustaDb()
	{
		$joku = new DatabaseHelper();
		$option = $joku->get('option');
		
		$db = & JDatabase::getInstance( $option );
		$this->setDBO($db);
		
	}
	
	function getEvent($id)
	{
		if(empty($this->_eventData)) 
		{
			$query = "SELECT * FROM ".getGlobalDbPrefix()."tapahtuma where id= ".$id;
    		$this->_eventData = $this->_getList($query);
			
			return $this->_eventData;
    	}
	
	}
	
	function getPicture($tapahtuma_id, $nimi = null)
	{

		
		if(empty($this->_picture)) 
		{
			$query = "SELECT * FROM ".getGlobalDbPrefix()."tiedosto where tapahtuma_id= ".$tapahtuma_id;
			if($nimi != null)
				$query = $query." AND nimi ='".$nimi."'";
			
			
			$this->_picture = $this->_getList($query);
			return $this->_picture;
    	}
		else 
		   return $this->_picture;
    }
	
	
	function getPosition($pos_id){

		$query = "SELECT * FROM ".getPositionDbPrefix()."dpposition where dpposition_id= ".(int) $pos_id;
		return $this->_getList($query);

	}

	
	
/*
	function tallennatapahtuma()
	{
		 $tapahtuma =& $this->getTable('tapahtuma');
		 $nimi = $_POST['nimi'];

		//print_r($_POST);
		  $tapahtuma =& JTable::getInstance('tapahtuma', 'Table');
		
		  $tapahtuma->nimi = $nimi;
		  $tapahtuma->store();
		
  		  return true;

	}
*/
}
?>